//package com.zmn.plat.task.listenter.part;
//
//import com.alibaba.fastjson.JSON;
//import com.alibaba.fastjson.JSONObject;
//import com.zmn.common.dictionary.GlobalDict;
//import com.zmn.common.dto.PushMsgDTO;
//import com.zmn.manager.mq.annotation.AliyunMQHandler;
//import com.zmn.manager.mq.annotation.AliyunMQListener;
//import com.zmn.plat.business.interfaces.part.PartSkuBService;
//import com.zmn.plat.constant.MessageQueueConstant;
//import com.zmn.plat.es.EsPartSkuService;
//import com.zmn.plat.model.es.part.EsPartSku;
//import com.zmn.plat.services.impl.part.PartMQService;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.stereotype.Component;
//
//import javax.annotation.Resource;
//
///**
// * @author DaiZhichao
// * @version v1.0
// * @since 2019/1/22 12:03
// * 类说明：如果有特殊说明加上这一行
// */
//@AliyunMQListener(topic = "${spring.mq.topic}")
//@Component
//public class PartQueueListenter {
//
//    private Logger logger = LoggerFactory.getLogger(this.getClass());
//    @Resource
//    PartSkuBService partSkuBService;
//    @Resource
//    EsPartSkuService esPartSkuService;
//
//    @AliyunMQHandler(tags = MessageQueueConstant.MQ_TAG_PLAT_PART_INDEX)
//    public void listen(String message) {
//        try {
//            PushMsgDTO pushMsgDTO = JSON.<PushMsgDTO>toJavaObject(JSON.parseObject(message), PushMsgDTO.class);
//            EsPartSku partSku = JSONObject.parseObject(pushMsgDTO.getBusinessData(), EsPartSku.class);
//            Integer skuId = Integer.parseInt(pushMsgDTO.getId());
//            String content = pushMsgDTO.getContent();
//            EsPartSku update = new EsPartSku();
//            String msg = null;
//            switch (content) {
//                case PartMQService.ACTION_PUSH:
//                    msg = esPartSkuService.putPartSku(partSku) ? "Elasticsearch新增配件成功：" : "Elasticsearch新增配件失败：";
//                    break;
//                case PartMQService.ACTION_EDIT:
//                    msg = esPartSkuService.editPartSku(partSku) ? "Elasticsearch修改配件成功：" : "Elasticsearch修改配件失败：";
//                    break;
//                case PartMQService.ACTION_REMOVE:
//                    msg = esPartSkuService.deletePartSku(skuId) ? "Elasticsearch删除配件成功：" : "Elasticsearch删除配件失败：";
//                    break;
//                case PartMQService.ACTION_ENABLE:
//                    update.setSkuId(skuId);
//                    update.setStatus((short) GlobalDict.STATUS_ENABLE);
//                    msg = esPartSkuService.editPartSku(update) ? "Elasticsearch启用配件成功：" : "Elasticsearch启用配件失败：";
//                    break;
//                case PartMQService.ACTION_DISABLE:
//                    update.setSkuId(skuId);
//                    update.setStatus((short) GlobalDict.STATUS_DISABLE);
//                    msg = esPartSkuService.editPartSku(update) ? "Elasticsearch禁用配件成功：" : "Elasticsearch禁用配件失败：";
//                    break;
//                default:
//                    break;
//            }
//
//            logger.info(msg, partSku);
//
//
//        } catch (Exception e) {
//            logger.error(e.getMessage(), e);
//            throw e;
//        }
//
//    }
//}
